#!/bin/bash

# MASCARAS DE RED
Netmask24="255.255.255.0"
Netmask25="255.255.255.128"
Netmask26="255.255.255.192"
Netmask27="255.255.255.224"
Netmask28="255.255.255.240"
Netmask29="255.255.255.248"
Netmask30="255.255.255.252"

# IPs
IP1="10.74.57.130"
IP2="10.74.63.129"
BROADCAST1="10.74.57.255"
BROADCAST2="10.74.63.191"

# DIRECCIONES DE RED
sanAntonio="10.74.63.0"
lasConchas="10.74.63.192"
calchaqui="10.74.63.224"
uruguay="192.168.53.0"
acaraguay="10.31.17.0"
chirimay="10.31.17.128"
uruguari="10.31.17.64"
iguazu="10.97.5.0"
gualeguay="10.74.57.0"
hernandarias="10.74.63.128"
bululu="10.74.63.240"
nogoya="10.74.63.244"

# DIRECCIONES DE GATEWAYS
H116="10.74.57.1" #interfaz1->IP1
H124="10.74.63.130" #interfaz2->IP2

./limpiezaInterfaces.sh
interfaz1=`ifconfig | egrep "eth." -o | head -1`
interfaz2=$interfaz1":0"
#Desactivo el ruteo del sistema operativo
echo "0" >> /proc/sys/net/ipv4/ip_forward


#CONFIGURACION INTERFACES Y RUTA


ifconfig $interfaz1 $IP1 broadcast $BROADCAST1 netmask $Netmask24
ifconfig $interfaz2 $IP2 broadcast $BROADCAST2 netmask $Netmask26

route add -net $sanAntonio netmask $Netmask24 dev $interfaz2 metric 2 gw $H124
route add -net $lasConchas netmask $Netmask27 dev $interfaz2 metric 2 gw $H124
route add -net $calchaqui netmask $Netmask29 dev $interfaz2 metric 2 gw $H124
route add -net $uruguay netmask $Netmask24 dev $interfaz2 metric 2 gw $H124
route add -net $acaraguay netmask $Netmask26 dev $interfaz1 metric 4 gw $H116
route add -net $chirimay netmask $Netmask25 dev $interfaz1 metric 2 gw $H116
route add -net $uruguari netmask $Netmask27 dev $interfaz1 metric 3 gw $H116
route add -net $iguazu netmask $Netmask24 dev $interfaz1 metric 4 gw $H116
route add -net $gualeguay netmask $Netmask24 dev $interfaz1
route add -net $hernandarias netmask $Netmask26 dev $interfaz2
route add -net $bululu netmask $Netmask30 dev $interfaz2 metric 1 gw $H124
route add -net $nogoya netmask $Netmask30 dev $interfaz1 metric 1 gw $H116

#CONFIGURACION SERVICIO
cp inetd.conf.telnet /etc/inetd.conf
/etc/init.d/openbsd-inetd restart 

#./DNSresto.sh


